package cn.dglydrpy.study;

import cn.dglydrpy.starter.EnableDglydrpyStarter;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;

import java.util.Arrays;
@Slf4j
// 默认扫描本启动类同级及同级以下的目录
@SpringBootApplication(scanBasePackages = "cn.dglydrpy.study",
//排除数据源自动配置  通过RouingDataSource选择使用mysql或oracle
exclude = { DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class,
        JdbcTemplateAutoConfiguration.class}
)
//持久层接口扫描
@MapperScan(basePackages = "cn.dglydrpy.study.*.mapper")
//启用自定义starter
@EnableDglydrpyStarter
public class SbmpApplication {

    public static void main(String[] args) {

        // 可通过System.setProperty指定application配置文件的值
        // System.setProperty("spring.devtools.restart.enabled", "false");

        SpringApplication.run(SbmpApplication.class, args);
    }


    @Bean
    public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
        return args -> {

            System.out.println("     Let's inspect the beans provided by Spring Boot!     ");

            String[] beanNames = ctx.getBeanDefinitionNames();
            Arrays.sort(beanNames);
            for (String beanName : beanNames) {
                System.out.println(beanName);
            }
        };
    }
}

